//
//  LKTicketOperateViewController.m
//  Mideleague_Shop
//
//  Created by Zhiwang on 2020/7/7.
//  Copyright © 2020 Zhiwang. All rights reserved.
//

#import "LKTicketOperateViewController.h"
#import "LKCustomKeyBoardView.h"
@interface LKTicketOperateViewController ()<LKCustomKeyBoardViewDelegate>

@property(nonatomic,strong)UITextField *moneyTf;

@end

@implementation LKTicketOperateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"卡券输入";
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = [UIColor whiteColor];
    [bgView setLayerShadow:[UIColor lightGrayColor] offset:CGSizeMake(1, 1) radius:3];
    [self.view addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(NAVIGATION_BAR_HEIGHT + 50);
       make.left.equalTo(self.view.mas_left).offset(30);
       make.right.equalTo(self.view.mas_right).offset(-30);
        make.height.mas_equalTo(80);
    }];

    bgView.layer.cornerRadius = 40;
//    bgView.layer.masksToBounds = YES;
    self.moneyTf = [[UITextField alloc] init];
    self.moneyTf.placeholder = @"请输入您的卡券号";
    self.moneyTf.textAlignment = NSTextAlignmentCenter;
    self.moneyTf.keyboardType = UIKeyboardTypeDecimalPad;
    LKCustomKeyBoardView *boradView = [[LKCustomKeyBoardView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, WIDTH) AndreturnTitle:@"确定"];
    boradView.delegate = self;
    self.moneyTf.inputView = boradView;
    [bgView addSubview:self.moneyTf];
    [self.moneyTf mas_makeConstraints:^(MASConstraintMaker *make) {
       make.left.equalTo(bgView.mas_left).offset(20);
       make.right.equalTo(bgView.mas_right).offset(-20);
       make.centerY.equalTo(bgView);
    }];
    // Do any additional setup after loading the view.
}
#pragma mark -LKCustomKeyBoardViewDelegate

-(UIButton *)lkClickConten:(UIButton *)contenBtn{
    self.moneyTf.text = [NSString stringWithFormat:@"%@%@",self.moneyTf.text,contenBtn.currentTitle];
    return contenBtn;
}
-(UIButton *)lkClickDelete:(UIButton *)deleteBtn{
    [self.moneyTf deleteBackward];
    return deleteBtn;
}
-(UIButton *)lkClickClear:(UIButton *)clearBtn{
    self.moneyTf.text = @"";
    return clearBtn;
}
-(UIButton *)lkClickdetermine:(UIButton *)determineBtn{
    NSLog(@"点击了%@",determineBtn.currentTitle);
    NSMutableDictionary *param = [[NSMutableDictionary alloc] initWithDictionary:@{@"code":self.moneyTf.text}];
    NSString *sign = [NSString encoingWithDic:param];
    [param setObject:sign forKey:@"sign"];
    [[LKNetDataManager defaultManager] sendRequestMethod:HTTPMethodPOST serverUrl:ServerlUrl apiPath:Mycancel_couponsUrl header:[LKUserInforTool account].token parameters:param progress:^(NSProgress * _Nullable progress) {
        
    } success:^(BOOL isSuccess, id  _Nullable responseObject) {
        if ([responseObject[@"code"] isEqualToString:@"success"]) {
            
        }else{
            [SVProgressHUD showInfoWithStatus:responseObject[@"msg"]];
        }
    } failure:^(NSString * _Nullable errorMessage) {
        
    }];
    return determineBtn;
}

/**
 *  周边加阴影，并且同时圆角
 */
- (UIView *)addShadowToView:(UIView *)view withOpacity:(float)shadowOpacity shadowRadius:(CGFloat)shadowRadius andCornerRadius:(CGFloat)cornerRadius {
    view.layer.cornerRadius = cornerRadius;
    view.layer.masksToBounds = YES;
    UIView *shadowView = [[UIView alloc] init];
    shadowView.layer.shadowColor = [UIColor blackColor].CGColor;
    shadowView.layer.shadowOffset = CGSizeMake(0, 0);
    shadowView.layer.shadowOpacity = shadowOpacity;
    shadowView.layer.shadowRadius = shadowRadius;
    shadowView.layer.cornerRadius = cornerRadius;
    shadowView.clipsToBounds = NO;
    [shadowView addSubview:view];
    return shadowView;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
